<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>拖车业务管理</title>
    <jsp:include page="../../head.jsp"/>

    <!-- 自定义style -->
    <style>
        .dataTB {
            width: 100%;
            border: 1px solid #ccc;
            line-height: 30px;
        }

        td.dataTD {
            font-weight: bold;
        }
    </style>
    <!-- 自定义style -->
    <!-- 自定义script -->
    <script type="text/javascript">
        $(function () {
            initFuncButton();
        });

        function initFuncButton() {
            $("button").attr("disabled", true);
            var trailState = "${trail.trailState}";
            if (trailState == "TS01") {
                $("#vpassBtn").attr("disabled", false);
                $("#vrejectBtn").attr("disabled", false);
            }
            $("#returnBtn").attr("disabled", false);
        }

        function validatePass() {
            var id = "${trail.id}";

            var iddata = "id=" + id;
            $.ajax({
                       url: "trail-checkValidatePass",
                       dataType: "json",
                       data: iddata,
                       success: function (data) {
                           if (!data) {
                               return;
                           }
                           var msg = data.msg ? $.parseJSON(data.msg) : "";
                           if (msg.state == 1) {
                               jw.confirm("确定要该业务通过审核?", function () {
                                              $.ajax({
                                                         url: "trail-validatePass",
                                                         dataType: "json",
                                                         data: iddata,
                                                         success: function (data) {
                                                             jw.alert(msg.msg,
                                                                      {
                                                                          onOk: function () {
                                                                              window.location.href =
                                                                                      "trail-listForSupToValidate";
                                                                          }
                                                                      });
                                                         }
                                                     });
                                          },
                                          function () {
                                              return;
                                          });
                           }
                           else if (msg !== undefined && msg != "" && msg.state == 0) {
                               jw.alert("只有处于待审核状态的业务才可以进行审核操作。");
                           }
                           else {
                               jw.alert(msg.msg);
                           }
                       }
                   });
        }

        function validateReject() {
            var id = "${trail.id}";

            var iddata = "id=" + id;
            $.ajax({
                       url: "trail-checkValidatePass",
                       dataType: "json",
                       data: iddata,
                       success: function (data) {
                           if (!data) {
                               return;
                           }
                           var msg = data.msg ? $.parseJSON(data.msg) : "";
                           if (msg.state == 1) {
                               jw.confirm("确定要驳回该业务?", function () {
                                              jw.dialog({
                                                            iframe: '../business/rejectContent-reject?id=' + id
                                                                    + "&type=2",
                                                            title: "驳回",
                                                            iframeFetchTitle: false,
                                                            width: 600,
                                                            height: 150
                                                        });
// 					$.ajax({
// 						url : "trail-validateReject",
// 						dataType : "json",
// 						data : iddata,
// 						success : function(data) {
// 							jw.alert($.parseJSON(data.msg).msg,
// 									{
// 										onOk: function() {
// 											window.location.href="trail-listForSupToValidate";
// 										}
// 									});
// 						}
// 					});
                                          },
                                          function () {
                                              return;
                                          });
                           }
                           else if (msg !== undefined && msg != "" && msg.state == 0) {
                               jw.alert("只有处于待审核状态的业务才可以进行驳回业务操作。");
                           }
                           else {
                               jw.alert(msg.msg);
                           }
                       }
                   });
        }
    </script>

</head>
<body>
<fieldset>
    <legend>下单公司：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">公司名称/联系人：</td>
            <td class="dataTD">
                <s:property value="trail.customer.name"/>/<s:property
                    value="trail.customer.contactor"/>
            </td>
        </tr>
        <tr>
            <td class="labelTD">地址：</td>
            <td class="dataTD"><s:property value="trail.customer.address"/></td>
            <td class="labelTD">电话：</td>
            <td class="dataTD"><s:property value="trail.customer.phone"/></td>
            <td class="labelTD">传真：</td>
            <td class="dataTD"><s:property value="trail.customer.fax"/></td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>出口公司：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">公司名称/联系人：</td>
            <td class="dataTD">
                <s:property value="trail.shipper.company"/>/<s:property value="trail.shipper.name"/>
            </td>
        </tr>
        <tr>
            <td class="labelTD">地址：</td>
            <td class="dataTD"><s:property value="trail.shipper.address"/></td>
            <td class="labelTD">电话：</td>
            <td class="dataTD"><s:property value="trail.shipper.phone"/></td>
            <td class="labelTD">传真：</td>
            <td class="dataTD"><s:property value="trail.shipper.fax"/></td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>SO信息：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">SO：</td>
            <td class="dataTD"><s:property value="trail.so"/></td>
            <td class="labelTD">SO文件：</td>
            <td class="dataTD">
                <s:if test="trail.soDoc==null">没有SO文件下载</s:if><s:else><a
                    href="download?attachment.id=<s:property value="trail.soDoc.id"/>"
                    target="_blank">点击下载SO文件</a></s:else>
            </td>
        </tr>
        <!-- 	<tr> -->
        <!-- 		<td class="labelTD">SO：</td> -->
        <%-- 		<td class="dataTD"><s:property value="trail.so"/></td> --%>
        <!-- 		<td class="labelTD">SO文件：</td> -->
        <%-- 		<td class="dataTD"><s:property value="trail.soDoc"/></td> --%>
        <!-- 	</tr> -->
        <!-- 	<tr> -->
        <!-- 		<td class="labelTD">SO相关业务信息：</td> -->
        <!-- 		<td class="dataTD"> -->
        <!-- 		<a href="#">点击查看</a> -->
        <!-- 		</td> -->
        <!-- 	</tr> -->
    </table>
</fieldset>
<fieldset>
    <legend>货柜信息：</legend>
    <table class="dataTB">
        <s:iterator value="ctAddressDTOList" var="ctAddress">
            <tr>
                <td class="labelTD">柜型</td>
                <td class="dataTD">
                    <s:property value="#ctAddress.container.ct_size"/>'<s:property
                        value="#ctAddress.container.ct_type"/>
                </td>
            </tr>
        </s:iterator>
    </table>
</fieldset>
<fieldset>
    <legend>装运地点信息：</legend>
    <table class="dataTB" rules="rows">
        <s:iterator value="ctAddressDTOList" var="ctAddress">
            <tr>
                <td class="labelTD">
                    货柜信息：<s:property value="#ctAddress.container.ct_size"/>'<s:property
                        value="#ctAddress.container.ct_type"/><br/>
                    货物信息：<s:property value="#ctAddress.goodsName"/><br/>
                    柜号:<s:property value="#ctAddress.container.containerNo"/><br/>
                    封条号:<s:property value="#ctAddress.container.seal"/>
                </td>
                <td class="">
                    <table class="dataTB">
                        <s:iterator value="#ctAddress.goodAddresses" var="gaddress">
                            <tr>
                                <td class="">
                                    <table class="dataTB">
                                        <tr>
                                            <td class="labelTD">工厂名称：
                                            </td>
                                            <td class="dataTD"><s:property
                                                    value="#gaddress.contacter.company"/>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="labelTD">工厂地址：
                                            </td>
                                            <td class="dataTD"><s:property
                                                    value="#gaddress.contacter.address"/>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="labelTD">联系方式：
                                            </td>
                                            <td class="dataTD"><s:property
                                                    value="#gaddress.contacter.name"/>/<s:property
                                                    value="#gaddress.contacter.phone"/>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="labelTD">备注：
                                            </td>
                                            <td class="dataTD"><s:property
                                                    value="#gaddress.remark"/>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </s:iterator>
                    </table>
                </td>
            </tr>
        </s:iterator>
        <tr>
            <td class="labelTD">柜总计：</td>
            <td><span style="margin-left:20px;"><s:iterator value="containerTotle"
                                                            var="size_type"><s:property
                    value="value"/>X<s:property value="key"/><s:if
                    test="!#size_type.isLast">/</s:if>
            </s:iterator></span></td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>操作选项</legend>
    <button ID="vpassBtn" onclick="validatePass();">通过审核</button>
    <button ID="vrejectBtn" onclick="validateReject();">驳回业务</button>
    <button id="returnBtn" onclick="location.href='trail-listForSupToValidate';">返回</button>
</fieldset>
</body>
</html>
